Update openai module compiler plugin to support generate API calls when the openai import is not present in the file#22
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22 +/- ##
=======================================
Coverage 35.74% 35.74%
=======================================
Files 5 5
Lines 442 442
Branches 112 112
=======================================
Hits 158 158
Misses 284 284 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the AI module compiler plugin to support generating API calls even when the AI import is not present in the file being processed. The change addresses issue #8126 by modifying how the OpenAI model provider symbol is retrieved and referenced during code analysis.
Key changes:
- Refactored symbol resolution to use the
Types.getTypeByName()API instead of searching through visible symbols - Modified the analysis flow to pass the resolved OpenAI model provider symbol to document processing methods
- Added test coverage for the scenario where AI imports are not present in the file
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| GenerateMethodModificationTask.java | Updated symbol resolution logic to use Types.getTypeByName() and removed dependency on visible symbols |
| test_values.bal | Added reviewRecord constant for test assertions |
| test-generate-method-usage-in-file-without-ai-import.bal | New test file to verify functionality without AI imports |
| Dependencies.toml | Updated dependency versions for ballerina/ai and ballerinax/ai.openai |
| CompilerPlugin.toml | Updated compiler plugin JAR path to new version |
| Ballerina.toml | Updated package version and native dependency path |
Comments suppressed due to low confidence (1)
compiler-plugin/src/main/java/io/ballerina/lib/ai/openai/GenerateMethodModificationTask.java:142
- [nitpick] The parameter name 'openAiModelProviderSymbol' in the method call is inconsistent with the variable name 'openAiModelProviderSymbol' declared at line 110. Consider using consistent naming throughout the method.
analyzeGenerateMethod(semanticModel, modulePartNode, openAiModelProviderSymbol, this.analysisData);
Update ai module compiler plugin to support generate API calls when the ai import is not present in the file
Fixes: ballerina-platform/ballerina-library#8126